package com.akcome.apollo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.akcome.apollo.domain.VStatsUsersDay;
import com.akcome.apollo.domain.VStatsUsersHour;

/**
 * Repository接口
 *
 * @author wn
 * @version $v: 1.0.0, $time:2017-12-26 08:49:00 Exp $
 */
public interface VStatsUsersDayRepository extends JpaRepository<VStatsUsersDay,Long>,JpaSpecificationExecutor<VStatsUsersDay> {

	@Query(nativeQuery=true,value="select ifnull(sum(earn),0) from v_stats_users_day where puid=?1")
	Long sumEarnByPuid(Long puid);
	
	@Query(nativeQuery=true,value="select * from v_stats_users_day where puid=?1 and day BETWEEN ?2 and ?3 and cointype=?4 order by day")
	List<VStatsUsersDay> findByPuidAndhourBetween(Long puid,String beginDate,String endDate,String coinType);
}
